package com.example.api.client.fallback;

import com.common.domain.R;
import com.example.api.client.UserClient;
import com.example.api.domain.entity.Subscribe;
import com.example.api.domain.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Slf4j
public class UserClientFallBack implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        return new UserClient() {
            @Override
            public R login(User user) {
                return null;
            }

            @Override
            public R getById(Long userId) {
                log.info("远程调用User-Model::getById接口错误");
                return R.ok().data(null);
            }

            @Override
            public R<List<User>> list(Set<Long> ids) {
                System.out.println("获取用户列表失败失败咯");
                return null;
            }

            @Override
            public R<List<Subscribe>> getUserSubscribe(Long id) {
                return R.ok().msg("获取订阅失败咯");
            }

            @Override
            public R<List<Long>> getAttention(Long id) {
                return null;
            }

            @Override
            public R collectVideo(Long collectId, Long videoId) {
                return null;
            }
        };
    }
}
